app.factory('goodsList',['$http',function($http){

    return {
        goodsList:function(){
            return $http.get('/goods/getList');

        },
        category:function (){
            return $http.get('/goodList/add');
        }

    }
}]);
app.factory('orderList',['$http',function($http){

    return{
        //路由
        getOrder:function(){
            return $http.get('/orderList/getOrder');
        },
        orderDelete:function(){
            return $http.get('/orderList/deleteOrder');
        },
        orderAdd:function(){
            return $http.all('/orderList/addOrder');
        },
        getCart:function(){
            return $http.get('/orderList/getCart');
        },
        deleteCart:function(){
            return $http.all('/orderList/deleteCart');
        }

    }

}]);
app.factory('cartServer',function(){
    return{
        amount:0,
        add:function(i){

            i++;
            this.amount=i;
        },
        minus:function(i){
            i--;
            if(i<=1){
                i=1;
            }
            this.amount=i;
        },
        sizePrice:function(size,price){
            return size*price;
        },
        total:function(amount,sizePrice){
            return amount*sizePrice;
        },
        orderContent:{},
        checkId:function(id){
            angular.forEach(order,function(val,key){
                if(id==val.id){
                    productContent.push(val)
                }
            });
            return productContent;
        }

    }

});
